from django.db import models

# Create your models here.

class Users(models.Model):
    userId = models.AutoField(primary_key=True)
    userName = models.CharField(db_index=True,unique=1,max_length=32)
    realName = models.CharField(max_length=32,default='')
    passWord = models.CharField(max_length=128,default='')
    email = models.EmailField(max_length=128,)
    isActive = models.IntegerField(default=1)
    isSuper = models.IntegerField(default=0)
    groupId = models.IntegerField(default=0)

    def __str__(self):
        return self.userName
#超级管理员：
    #用户管理
# developer：
    #数据查询（脱敏）
    #SQL上线申请
#市场&运营部
    #数据提取
#DBA
    #DB备份
    #DB集群搭建
    #DB性能分析
    #DB高可用管理
    #敏感数据脱敏

class UserGroup(models.Model):
    groupId = models.AutoField(primary_key=True)
    groupName = models.CharField(unique=1,max_length=128,default='')
    isActive = models.IntegerField(default=1)

    def __str__(self):
        return self.name

class UserGroupRel(models.Model):
    groupId = models.IntegerField(db_index=1)
    userId = models.IntegerField(db_index=1)
    isActive = models.IntegerField(default=1)

    def __str__(self):
        return self.name

class Role(models.Model):
    roleId = models.AutoField(primary_key=True)
    roleName = models.CharField(null=0,max_length=128,default='')
    key = models.CharField(unique=1,max_length=32,default='')
    url = models.CharField(unique=1,max_length=128,default='')
    isActive = models.IntegerField(default=1)
    classStyle = models.CharField(max_length=128,default='')


    def __str__(self):
        return self.name

class GroupRoleRel(models.Model):
    groupId = models.IntegerField(db_index=1)
    roleId = models.IntegerField(db_index=1)
    isActive = models.IntegerField(default=1)
    isdefault = models.IntegerField(default=1)

    def __str__(self):
        return self.name